package com.example.card.transactionimplementation;

import com.example.card.domain.card.Card;
import com.example.card.CardConstant;
import com.example.card.CardDataBase;
import com.example.card.abstracttransactions.CardModifyTransaction;

public class CardUnbindTransaction extends CardModifyTransaction {

    public CardUnbindTransaction(int memberId, int id) {
        super(memberId, id);
    }

    @Override
   public void change(Card card) {
        if (CardConstant.STATUS_NORMAL == card.getStatus()
                || CardConstant.STATUS_DISABLE == card.getStatus()
                || CardConstant.STATUS_FROZEN == card.getStatus()
                || CardConstant.STATUS_COMPLETED == card.getStatus()) {
            CardDataBase.unbindCard(memberId, id);
        } else {
            throw new RuntimeException("该状态无法解绑卡片");
        }
    }
}
